<?php
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/model/factory/DaoFactory.php';
	
	error_reporting (E_ALL ^ E_NOTICE);
	
	$debug = $_SESSION['debug'];
	
	/*
	* Class to select all existing news
	*/
	class CommandSelectNews extends CustomCommand {
		/*
		 * Constructor of the class
		 */
		public function __construct() {
				
		}
		
		/*
		 * Method to execute to select all existing news
		 */
		public function execute() {
			$daoFactory = DaoFactory :: getMySqlDaoFactory();
			$inad = $daoFactory -> getMySqlNewsAccessDao();			
			$sentence = $inad -> selectNews();
			
			$news = ''; $i = 0;
			while ($row = mysql_fetch_array($sentence)) {
				$news['date'][$i] = $row['date'];
				$news['image'][$i] = $row['image'];
				$news['title'][$i] = $row['title'];
				$news['description'][$i++] = $row['description'];
			}			

			$this -> result = $news;
		}
	}
?>